package com.wxmp.wxapi.service.impl;

import com.wxmp.wxapi.service.PushService;
import com.wxmp.wxcms.domain.Account;
import com.wxmp.wxcms.domain.AccountFans;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;
import java.util.Optional;

/**
 * @Author zzm
 * @Date 2022/8/23 14:20
 * @Version 1.0
 **/
@Component
public class PushFactory {

    @Resource
    private Map<String, PushService> map;


    public void push(String key, AccountFans accountFans, String templateId, Account account){
        PushService pushService = Optional.ofNullable(map.get(key)).orElseThrow(() -> new IllegalArgumentException("Invalid Operator"));
        pushService.push(accountFans,templateId,account);
    }
}
